﻿/*-------------------------------------
//
//Copyright (C) 2007 开发二组 版权所有。
//
//文件名：V_OrderItem.cs
//
//
//文件功能描述：对应数据库中V_OrderItem视图的数据操作接口以SQL2000的操作来实现
//
//
//创建标识：2007.11.15 王林进
//创建描述：机器生成
//
//
//
//------------------------------------*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using JXMSTC.SmartBusiness.DAL.IDAL;
using JXMSTC.SmartBusiness.DAL.DbHelperSQL;//数据访问抽象基类
namespace JXMSTC.SmartBusiness.DAL.SQL2000DAL
{
    /// <summary>
    /// 数据访问类V_OrderItem 。
    /// </summary>
    public class V_OrderItem : IV_OrderItem
    {
        public V_OrderItem()
        { }
        #region  成员方法
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JXMSTC.SmartBusiness.Common.Model.V_OrderItem GetModel(string OrderInfoID,string ProductID)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@OrderInfoID", SqlDbType.Int,4),
                    new SqlParameter("@ProductID", SqlDbType.Int,4)
				};
            parameters[0].Value = OrderInfoID;
            JXMSTC.SmartBusiness.Common.Model.V_OrderItem model = new JXMSTC.SmartBusiness.Common.Model.V_OrderItem();

            DataSet ds = DbHelperSQL.DbHelperSQL .RunProcedure("UP_V_OrderItem_GetModel", parameters, "ds");
            model.OrderInfoID = OrderInfoID;
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.OrderInfoID = ds.Tables[0].Rows[0]["OrderInfoID"].ToString();
                model.ProductID = ds.Tables[0].Rows[0]["ProductID"].ToString();
                model.LowerCategory = ds.Tables[0].Rows[0]["LowerCategory"].ToString();
                model.Unit = ds.Tables[0].Rows[0]["Unit"].ToString();
                if (ds.Tables[0].Rows[0]["Quantity"].ToString() != "")
                {
                    model.Quantity = int.Parse(ds.Tables[0].Rows[0]["Quantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UnitPrice"].ToString() != "")
                {
                    model.UnitPrice = decimal.Parse(ds.Tables[0].Rows[0]["UnitPrice"].ToString());
                }
                model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 获取数据列表
        /// </summary>
        public DataSet GetList()
        {
            SqlParameter[] parameters = { };
            return DbHelperSQL.DbHelperSQL .RunProcedure("UP_V_OrderItem_GetList", parameters, "ds");
        }

        /// <summary>
        /// 获取数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            SqlParameter[] parameters = { new SqlParameter("@strWhere", SqlDbType.VarChar, 100) };
            parameters[0].Value = strWhere;
            return DbHelperSQL.DbHelperSQL .RunProcedure("UP_V_OrderItem_GetList", parameters, "ds");
        }

        /// 修改标识：2007.11.29 李鹏
        /// 修改描述：修改参数 @fldName,由 OrderInfoID 改为 ProductID
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize, int PageIndex, string strWhere)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
            parameters[0].Value = "V_OrderItem";
            parameters[1].Value = "ProductID";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;
            return DbHelperSQL.DbHelperSQL .RunProcedure("UP_GetRecordByPage", parameters, "ds");
        }

        ///// <summary>
        ///// 分页获取数据总行数
        ///// </summary>
        public DataSet GetListRows(string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "V_OrderItem";
            parameters[1].Value = "OrderInfoID";
            parameters[2].Value = 10;
            parameters[3].Value = 1;
            parameters[4].Value = 1;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;
            return DbHelperSQL.DbHelperSQL.RunProcedure("UP_GetRecordByPage", parameters, "ds");
        }
        #endregion  成员方法
    }
}

